import {FrameBuffer} from "../output/FrameBuffer";
import {ZBuffer} from "../output/ZBuffer";
import {Scene} from "./Scene";
import {OrthographicCamera} from "./OrthographicCamera";
import {Matrix4} from "../math/Matrix4";
import {ObjFile} from "../asserts/ObjFile";
import {Vector4} from "../math/Vector4";
import {Vector3} from "../math/Vector3";
import {MathUtil} from "../math/MathUtil";
import {DrawTriangleUtil} from "../utils/DrawTriangleUtil";

export class Renderer {
    width: number;
    height: number;

    frameBuffer: FrameBuffer;
    zBuffer: ZBuffer;

    canvasMatrix: Matrix4;

    constructor(width: number, height:number) {
        this.width = width;
        this.height = height;
        this.frameBuffer = new FrameBuffer(this.width, this.height);
        this.zBuffer = new ZBuffer(this.width, this.height);
        this.canvasMatrix = new Matrix4().makeScale(2 / this.width, -2 / this.height, 1).multiply(new Matrix4().makeTranslation(1, -1, 0));
    }

    setSize(width: number, height: number) {
        this.frameBuffer.setSize(width, height);
        this.zBuffer.setSize(width, height);
        this.width = width;
        this.height = height;
    }

    render(scene: Scene, camera: OrthographicCamera) {
        for (const obj of scene.objects) {
            const modelMatrix = obj.getMatrix();
            const viewMatrix = camera.getViewMatrix();
            const projectMatrix = camera.getProjectMatrix();

        }
    }

}